package com.yh.service.impl;

import com.yh.dao.ZhanfengConfigDAO;
import com.yh.entity.ZhanfengConfig;
import com.yh.service.ConfigService;

public class ConfigServiceImpl implements ConfigService{

	private ZhanfengConfigDAO dao = new ZhanfengConfigDAO();
	
	@Override
	public long getCount() {
		try {
			ZhanfengConfig config = dao.selectById("count");
			return config.getConfigValue();
		} catch (Exception e) {
			return 0;
		}
	}

	@Override
	public void saveCount(long count) {
		ZhanfengConfig config = null;
		try {
			config = dao.selectById("count");
			config.setConfigValue(count);
			dao.updateById(config);
		} catch (Exception e) {
			config = new ZhanfengConfig();
			config.setConfigKey("count");
			config.setConfigValue(count);
		}
		
	}

}
